//
//  ChannelCell.m
//  TestApplication
//
//  Created by Hanlingyu on 16/9/10.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "ChannelCell.h"
#import "TAMacro.h"
#import "ChannelCellFrameViewModel.h"


#define cellMargin 10
@interface ChannelCell ()



           
@end



@implementation ChannelCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor colorWithWhite:0.917 alpha:1];
        // 添加所有子控件的方法
        [self setUpAllChildViews];
        
    }
    return self;
}

// 添加所有子控件的方法
- (void)setUpAllChildViews {
    // 内容
    ChannelContentView *channelContentView = [[ChannelContentView alloc] init];
    [self.contentView addSubview:channelContentView];
    channelContentView.backgroundColor = [UIColor whiteColor];
    _channelContentView = channelContentView;
    
    // 工具条
    ChannelToolBar *toolBar = [[ChannelToolBar alloc] init];
    [self.contentView addSubview:toolBar];
    toolBar.backgroundColor = [UIColor whiteColor];
    _channelToolBar = toolBar;
    
    // 评论
    HotCommentView *commentView = [[HotCommentView alloc] init];
    [self.contentView addSubview: commentView];
    commentView.backgroundColor = [UIColor yellowColor];
    _commentView = commentView;
    
}

- (void)setChannelCellFrame:(ChannelCellFrameViewModel *)channelCellFrame {
    _channelCellFrame = channelCellFrame;
    // 内容的frame
    _channelContentView.frame = _channelCellFrame.channelContentViewFrame;
    // 工具的frame
    _channelToolBar.frame = _channelCellFrame.toolViewFrame;
    // 评论的frame
    _commentView.frame = _channelCellFrame.hotCommentViewFrame;
    // 传递数据
    _channelContentView.channelCellFrame = _channelCellFrame;
    _channelToolBar.channelCellFrame = _channelCellFrame;
    _commentView.channelCellFrame = _channelCellFrame;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
